package com.ming.stringstudy.feedbacksystem.Exception;


import com.ming.stringstudy.feedbacksystem.pojo.Result;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    @Order(2) // 优先级低后执行
    public Result ex(Exception ex) {
        ex.printStackTrace();
        return Result.error("对不起，操作失败，请联系管理员");
    }

    @ExceptionHandler(value = PermissionDeniedException.class)
    @Order(1)// 优先执行
    public Result permissionDenied(PermissionDeniedException permissionDeniedException){
        permissionDeniedException.printStackTrace();
        return Result.error("权限不足");
    }
}
